package com.pt25.service.sys.interfaces.facade.inner;


import com.pt25.base.res.ResBody;
import com.pt25.service.sys.application.CodegenApp;
import com.pt25.service.sys.interfaces.assembler.CodegenAssembler;
import com.pt25.service.sys.interfaces.vo.codegen.CodegenVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "codegen inner api")
@RestController
@RequestMapping("/inner-api/sys")
public class CodeGenInnerController {

    private final static String GENCODE = "/gencode";

    @Resource
    private CodegenApp codegenApp;

    /*
     测试数据:
     {
     "basePackage": "com.pt25.service.sys",
     "service": "sys",
     "domain": "config",
     "url": "jdbc:mysql://172.16.64.252:3306/pt",
     "user": "root",
     "password": "7502Newsdi@",
     "tableName": "sys_config_type",
     "modelName": "config_type"
     }
     */
    @PostMapping(GENCODE)
    public ResBody genCode(@RequestBody @Valid CodegenVo codegenVo) {
        codegenApp.genCode(CodegenAssembler.codegenVO2Codegen(codegenVo));
        return ResBody.builder().build().ok();
    }
}
